#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=5e5+5;
inline int read(){
	int x=0,f=1;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=(x<<1)+(x<<3)+ch-48,ch=getchar();}
	return x*f;
}
int n,q,l[N],r[N];
signed main(){
	freopen("study.in","r",stdin);
	freopen("study.out","w",stdout);
	n=read(),q=read();
	for(int i=1;i<n;i++) l[i]=read(),r[i]=read();
	while(q--){
		int opt=read();
		if(opt==1){
			int p=read();
			l[p]=read(),r[p]=read();
		}
		else{
			int u=read(),s=read(),v=read(),t=read();
			if(u==v){
				puts("0");
				continue;
			}
			int res=0;
			if(u<v){
				while(u^v){
					int L=l[u],R=r[u]-1;
					if(s>R) res+=s-R,s=R;
					s=max(s,L),s++,u++; 
				}
			}
			else{
				while(u^v){
					int L=l[u-1],R=r[u-1]-1;
					if(s>R) res+=s-R,s=R;
					s=max(s,L),s++,u--; 				
				}
			}
			res+=max(0ll,s-t);
			printf("%lld\n",res);			
		}
	}
	return 0;
}
